#!/bin/bash

lastfile=""
if [[ ! $* ]]; then
   echo "usage: $0 <directory>"
   exit 1
fi
if [[ ! -e "$1/old/" ]]; then
   mkdir "$1/old/"
fi
for file in $(ls -r $1); do
   stripped=${file%%-[0-9].*}
   if [[ "$stripped" == "$lastfile" ]]; then
      echo "moved duplicate $1/$file"
      mv "$1/$file" "$1/old/"
   fi
   lastfile=$stripped
done
